<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018\9\10 0010
 * Time: 14:50
 */

namespace app\Lib\Model\Role;


use app\Lib\InterfaceIn\Role\RolePublicHandle;

class RolePublic implements RolePublicHandle
{
    private $roleDb;
    private function getRoleDb(){
        if(empty($this->roleDb)){
            $this->roleDb = new \app\Lib\Model\DbModel\Role();
        }
        return $this->roleDb;
    }
    /**
     * 获取全部角色按照key('id')=>value('Name')形式返回
     * @return array
     */
    public function getAllRoleKeyIdValueName()
    {
        $data = [];
        $data[0] = '顶级';
        $ids = $this->getRoleDb()->column($this->getRoleDb()->_id);
        if(is_array($ids) && !empty($id)){
            foreach ($ids as $v){
                $data[$v]=(new Role($v))->getName();
            }
        }
        return $data;
    }

}